<?php
//控制器基类
class Controller{
	protected $_vars=array();
	public function __set($var,$value){
		$this->assign($var,$value);
	}
	protected function display($tpl){
		$tpl = TPL_PATH.$tpl;
		if(!is_file($tpl)){
			halt('出错了，模板文件'.$tpl.'不存在');
		}
		//将属性输出到符号表
		extract($this->_vars);
		require $tpl;
	}
	//向模板分配变量
	protected function assign($var,$value){
		$this->_vars[$var]=$value;
	}
	/**
	 * 成功时显示方法
	 * @param  [type] $msg [description]
	 * @return [type]      [description]
	 */
	protected function success($message,$url=''){
		$this->assign('message',$message);
		$this->assign('url',$url);
		$this->display('success.html');
	}
	protected function error($message,$url=''){
		$this->assign('message',$message);
		$this->assign('url',$url);
		$this->display('error.html');	
	}

}